<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\assets\AppAsset;
use kartik\file\FileInput;

/* @var $this yii\web\View */
/* @var $searchModel backend\models\ProjectSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '项目管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="project-index">
    <div class="row">
        <div class="col-md-12">

            <div class="box box-solid collapsed-box">
                <div class="box-header with-border">
                    <h3 class="box-title">请选择Excel模板</h3>
                    <div class="box-tools">
                        <button class="btn btn-box-tool" type="button" data-widget="collapse">
                            <i class="fa fa-minus"></i>
                        </button>
                    </div>
                </div>
                <div class="box-body no-padding">
                    <ul class="nav nav-pills nav-stacked">
                        <li>
                            <a href="/excel_template/index.php?id=1">
                                <i class="fa fa-circle-o text-yellow"></i>
                                项目详情表
                            </a>
                        </li>
                    </ul>
                </div>
            </div>

            <div class="box box-solid  collapsed-box">
                <div class="box-header with-border">
                    <h3 class="box-title">Excel导入设备</h3>

                    <div class="box-tools">
                        <button class="btn btn-box-tool" type="button" data-widget="collapse">
                            <i class="fa fa-plus"></i>
                        </button>
                    </div>
                </div>
                <!-- /.box-header -->
                <!-- form start -->
                <div class="box-body" style="display: none;">
                    <?php
                    echo FileInput::widget([
                        'name' => 'excelFile',
                        'options' => [
                            'multiple' => true,
                            'accept' => 'application/vnd.ms-excel, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
                        ],
                        'pluginOptions' => [
                            'uploadUrl' => 'file-upload',
                            'uploadExtraData' => [
                                //'building_id' => Yii::$app->request->get('building_id'),
                            ],
                            'maxFileCount' => 1,
                        ]
                    ]);
                    ?>
                </div>
                <!-- /.box-body -->
            </div>

            <div class="box box-solid">
                <div class="box-header with-border"></div>
                <div class="box-body">
                    <p>
                        <?= Html::a('新建项目', ['create'], ['class' => 'btn btn-success']) ?>
                    </p>
                    <?= GridView::widget([
                        'dataProvider' => $dataProvider,
                        'filterModel' => $searchModel,
                        'columns' => [
                            ['class' => 'yii\grid\SerialColumn'],

                            //'id',
                            'project_name',
                            'eqip_name',
                            'add_user_name',
                            'content:ntext',
                            //'status',
                            [
                                'attribute' => 'status',
                                'value' =>
                                    function ($model) {
                                        return dropDown('status', $model->status);
                                    },
                                'filter' => dropDown('status'),
                            ],
                            [
                                'label' => '创建时间',
                                'attribute' => 'created_at',
                                'value' => function ($model) {
                                    return date('Y-m-d H:i:s', $model->created_at);
                                },
                            ],
                            [
                                'label' => '结束时间',
                                'attribute' => 'updated_at',
                                'value' => function ($model) {
                                    return date('Y-m-d H:i:s', $model->updated_at);
                                },
                            ],
                            //'created_at',
                            //'updated_at',

                            ['class' => 'yii\grid\ActionColumn'],
                        ],
                    ]); ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?= AppAsset::addScript($this, Yii::$app->request->baseUrl . "/bootstrap-datepicker/js/bootstrap-datepicker.js"); ?>
<?= AppAsset::addCss($this, Yii::$app->request->baseUrl . "/bootstrap-datepicker/css/bootstrap-datepicker.min.css"); ?>
